import { getPrescriptionApi } from '@/services/order'
import { showFailToast, showImagePreview } from 'vant'
import { ref } from 'vue'
export const viewPrescription = () => {
  const viewLoading = ref(false)
  const onShowPrescription = async (prescriptionId: string) => {
    try {
      viewLoading.value = true
      const { data } = await getPrescriptionApi(prescriptionId)
      console.log(data)
      showImagePreview([data.url])
    } catch (error) {
      showFailToast('获取处方失败')
    } finally {
      viewLoading.value = false
    }
  }

  return {
    viewLoading,
    onShowPrescription
  }
}
